import 'package:flutter/material.dart';

class MenuItem {
  final String title;
  final int id;

  MenuItem(this.title, this.id);
}



class PopupMenuButtonPage extends StatefulWidget {
  const PopupMenuButtonPage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _PopupMenuButtonPageState();
  }
}

class _PopupMenuButtonPageState extends State<PopupMenuButtonPage> {
  final List<MenuItem> _menuItems = [
    MenuItem('Option 1', 1),
    MenuItem('Option 2', 2),
    MenuItem('Option 3', 3),
  ];


  String selectedValue = '123123';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('PopupMenuButton Example'),
        ),
        body: Center(
          child: PopupMenuButton<MenuItem>(
            onSelected: (MenuItem selectedMenuItem) {
              setState(() {
                selectedValue = selectedMenuItem.title;
              });
            },
            itemBuilder: (BuildContext context) {
              return _menuItems.map((MenuItem menuItem) {
                return PopupMenuItem<MenuItem>(
                  value: menuItem,
                  child: Text(menuItem.title),
                );
              }).toList();
            },
            child: Text(selectedValue),
          ),
        ),
      ),
    );
  }
}